package com.kaitian.demo.demo_boot_starter.service.impl;

import com.kaitian.demo.demo_boot_starter.doc.DemoDoc;
import com.kaitian.demo.demo_boot_starter.repository.DemoDocRepository;
import com.kaitian.demo.demo_boot_starter.service.IDemoDocService;
import com.kaitian.demo.demo_boot_starter.utils.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

/**
 * @author ：xietian
 * @version ：V1.0
 * @program ：demo
 * @date ：Created in 2022/4/8 15:49
 * @description ：
 */
@Slf4j
@Service
public class DemoDocServiceImpl implements IDemoDocService {

    @Autowired
    private MongoTemplate mongoTemplate;

    @Autowired
    private RedisUtil redisUtil;

    @Autowired
    private DemoDocRepository demoDocRepository;

    @PostConstruct
    @Override
//    @CachePut(value = "redisCache:demo:", key = "#id")
    public DemoDoc testSave() {
        DemoDoc doc = new DemoDoc() {
            {
                this.setId(System.currentTimeMillis());
                this.setDemoText("xxxxx");
            }
        };
        return demoDocRepository.save(doc);
    }
}